<template>
  <!-- eslint-disable -->
  <div class="usersArr">
    <div class="topArea">
      <div class="inputSearch">
        <el-input v-model="searchConditions" placeholder="请输入姓名或手机号关键字搜索" style="width: 280px;" prefix-icon="el-icon-search" clearable @keyup.enter.native="handleSearchTable" />
      </div>
      <div class="topBtnGroup">
        <el-button type="primary" size="small" icon="el-icon-plus" @click="handleEnterAdduser">新增人员</el-button>
        <el-button type="primary" size="small" icon="el-icon-s-operation">批量导入</el-button>
      </div>
    </div>
    <div class="filter-container">
      <el-select v-model="screening.role" placeholder="请选择角色" clearable class="inputWidth">
        <el-option
          v-for="item in rolesList"
          :key="item.id"
          :label="item.title"
          :value="item.id"
        >
        </el-option>
      </el-select>
      <el-select v-model="screening.department" placeholder="请选择院系" clearable class="inputWidth">
        <el-option
          v-for="item in departmentsList"
          :key="item.id"
          :label="item.title"
          :value="item.id"
        >
        </el-option>
      </el-select>
      
      <el-select v-model="screening.grade" placeholder="请选择年级" clearable class="inputWidth">
        <el-option
          v-for="item in gradeList"
          :key="item.id"
          :label="item.title"
          :value="item.id"
        >
        </el-option>
      </el-select>
      <el-button style="width:100px;margin-bottom: 20px;" @click="handleScreeningChange">筛选</el-button>
      <i class="el-icon-refresh-left refresh" @click="handleClearScreening"></i>
    </div>

    <!-- 列表 -->
    <el-table :data="usersList" v-loading="loading" style="width: 100%">
      <el-table-column align="center" prop="role" label="角色"></el-table-column>
      <el-table-column align="center" prop="telephone" label="当前账号/手机号"></el-table-column>
      <el-table-column align="center" prop="name" label="姓名"></el-table-column>
      <el-table-column align="center" prop="department" label="所属院系"></el-table-column>
      <el-table-column align="center" prop="grade" label="管辖入学年级"></el-table-column>
      <el-table-column align="center" prop="addTime" label="添加时间"></el-table-column>
      <el-table-column align="center" prop="updateTime" label="变更时间"></el-table-column>
      <el-table-column align="center" prop="loginTime" label="最近登录时间"></el-table-column>
      <el-table-column align="center" label="操作">
        <template slot-scope="{row}">
          <el-tooltip effect="dark" content="查看" placement="top-start">
            <span class="btnIcon view" @click="handleEditUser(row)"></span>
          </el-tooltip>
          <el-tooltip effect="dark" content="删除" placement="top-start">
            <span class="btnIcon delete" @click="handleDeleteUser(row)"></span>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>

export default {
  data() {
    return {
      screening: { // 筛选条件
        department: '',
        role: '',
        grade: ''
      },
      searchConditions: '', // 搜索条件
      departmentsList: [{ // 院系列表
        id: '001',
        title: '计算机系'
      }],
      rolesList: [{ // 专业列表
        id: '001',
        title: '就业班主任'
      }, {
        id: '002',
        title: '院系就业负责人'
      }, {
        id: '003',
        title: '就业指导老师'
      }],
      gradeList: [{ // 年级列表
        id: '001',
        title: '2019'
      }, {
        id: '002',
        title: '2020'
      }, {
        id: '003',
        title: '2021'
      }, {
        id: '004',
        title: '2022'
      }],
      loading: false,
      usersList: [{
        id: '54212',
        name: '张晓东',
        telephone: '13212345678',
        department: '公共与行政管理学院',
        role: '就业班主任',
        grade: '2019',
        status: '已激活',
        addTime: '2019.02.13 12:02',
        updateTime: '2019.02.13 12:02',
        loginTime: '2019.02.13 12:02'
      }]
    }
  },
  methods: {
    // 点击'新增学生'按钮
    handleEnterAdduser() {
      this.$router.push({ path: './add' })
    },
    handleEditUser(row) {
      this.$router.push({
        path: './edit',
        query: {
          id: row.id
        }
      })
    },
    // 点击'筛选'按钮
    handleScreeningChange() {},
    // 点击'清空'按钮
    handleClearScreening() {
      this.screening['department'] = ''
      this.screening['role'] = ''
      this.screening['grade'] = ''
    },
    // 点击'搜索'按钮
    handleSearchTable() {
      console.log(this.searchConditions)
    },
    handleDeleteUser(row) {
      this.usersList = this.usersList.filter(x => x.id !== row.id)
    }
  }
}
</script>

<style lang="scss">
  $defaultColor: #0A2045;
  .usersArr {
    padding: 30px;
    .topArea {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 30px;
      .el-input--suffix .el-input__inner {
        padding-right: 0;
      }
    }
    .filter-container {
      .refresh {
        color: #B2B7C2;
        font-size: 20px;
        margin-left: 10px;
        cursor: pointer;
      }
      .inputWidth {
        margin-right: 10px;
        width: 224px;
        height: 38px;
        line-height: 38px;
      }
    }
  }
  // 标题头样式修改
  .el-table {
    color: $defaultColor;
    font-size: 14px;
    line-height: 19px;
    thead {
      color: $defaultColor;
      tr, th {
        background: #FAFAFB;
      }
    }
  }
  .el-button:focus, .el-button:hover {
    color: #0C66FF;
    border-color: #0C66FF;
    background-color: #fff;
  }
  .el-button--primary {
    color: #FFF;
    background-color: #0C66FF;
    border-color: #0C66FF;
  }
  .el-button--small {
    border-radius: 8px;
  }
  .el-button--primary:hover {
    color: #fff;
    background-color: #0951CC;
    border-color: #0951CC;
  }
  .btnIcon {
    display: inline-block;
    width: 24px;
    height: 24px;
    cursor: pointer;
    margin-right: 10px;
  }
  // 删除
  .delete {
    background: url('../../assets/btn/icon_delete.png') no-repeat center center;
  }
  .delete:hover {
    background: url('../../assets/btn/icon_delete_s.png') no-repeat center center;
  }
  // 查看
  .view {
    background: url('../../assets/btn/icon_eye.png') no-repeat center center;
  }
  .view:hover {
    background: url('../../assets/btn/icon_eye_s.png') no-repeat center center;
  }
</style>
